import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

// 配置路由
// 1、引入页面需要的组件
import { HomeComponent } from './components/home/home.component';
  import { WelcomeComponent } from './components/home/welcome/welcome.component';
  import { SettingComponent } from './components/home/setting/setting.component';
import { ProductComponent } from './components/product/product.component';
  import { PcateComponent } from './components/product/pcate/pcate.component';
  import { PlistComponent } from './components/product/plist/plist.component';

const routes: Routes = [
  {
    path:'home',component:HomeComponent,
    // 配置子路由
    children:[
      {path:'welcome',component:WelcomeComponent},
      {path:'setting',component:SettingComponent}
    ]
  },
  {
    path:'product',component:ProductComponent,
    children:[
      {path:'plist',component:PlistComponent},
      {path:'pcate',component:PcateComponent}
    ]
  },
  {path:"**",redirectTo:"home"}//匹配不到就直接跳转到home
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
